package tests;

import gui.FileListCellRenderer;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JList;

import logic.file.IFile;
import logic.file.LocalDirectory;
import logic.file.LocalFile;

@SuppressWarnings("serial")
public class SetVisibleTest extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SetVisibleTest frame = new SetVisibleTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SetVisibleTest() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		//TODO finalnie custom model bo, potrzebujemy wsadzić całą listę plików naraz, albo jlist.setListData
		DefaultListModel<IFile> model = new DefaultListModel<IFile>();
		JList<IFile> list = new JList<IFile>(model);
		list.setCellRenderer(new FileListCellRenderer());
		list.setVisibleRowCount(0);
		System.out.println(list.getVisibleRowCount());
		list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
		list.setFixedCellHeight(50);
		list.setFixedCellWidth(50);
		( (DefaultListModel<IFile>) list.getModel()).addElement(new LocalDirectory("javasfdgfdgdfgfdggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"));
		( (DefaultListModel<IFile>) list.getModel()).addElement(new LocalDirectory("java2"));
		( (DefaultListModel<IFile>) list.getModel()).addElement(new LocalFile("java3f"));
		contentPane.add(list, BorderLayout.CENTER);
		
		
	}

}
